

var formatNumber = function(n) {
	n = n.toString()
	return n[1] ? n : '0' + n
}

// 时间戳转日期 01/01 00:00
let formatDate = function(datetime) {
	let date = new Date(datetime);
	let month = date.getMonth() + 1;
	let day = date.getDate();
	let hour = date.getHours();
	let min = date.getMinutes();
	let sec = date.getSeconds();
	let year = date.getFullYear()
	return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, min, sec].map(formatNumber).join(':');
}


//html剔除富文本标签，留下纯文本
function getSimpleText(html) {
	let re1 = new RegExp("<.+?>", "g"); //匹配html标签的正则表达式，"g"是搜索匹配多个符合的内容
	let msg = html.replace(re1, ''); //执行替换成空字符
	return msg;
}

module.exports = {
	formatDate,
	getSimpleText,
}
